GC MRM Contrast Report

Setup and Processing

Code
library(tidyverse)
library(tictoc)
library(viridis)

# --- 1. Load Functions ---
# Adjust path if necessary to match your project structure
source("r/srm_analysis_scripts.R")

# --- 2. Configuration ---
ms_data_path <- "ms_data/"
# Using relative path from snippet
mrm_file_path <- "files/251103_mrms_rev5.csv"
Code
# --- 3. Process Data ---
# Load metadata if function exists (from sourced script)
if(exists("ms_metadataer")) {
  ms_metadataer(ms_data_path)
}
$instrument
$instrument$manufacturer
[1] "instrument model"

$instrument$model
[1] "Agilent instrument model"

$instrument$ionisation
[1] "electron ionization"

$instrument$analyzer
[1] "quadrupole"

$instrument$detector
[1] "electron multiplier"

$instrument$software
[1] "MassHunter 8.0"

$instrument$sample
[1] ""

$instrument$source
[1] ""


$run
$run$scanCount
[1] 0

$run$lowMz
[1] Inf

$run$highMz
[1] -Inf

$run$dStartTime
[1] Inf

$run$dEndTime
[1] -Inf

$run$msLevels
integer(0)

$run$startTimeStamp
[1] "2025-11-03T17:09:34Z"
Code
# Create dataframe with spectral and chromatographic info
sample_spectrums <- process_srm_batch(
  input = ms_data_path,
  mrm_info = read_csv(mrm_file_path, show_col_types = FALSE)
) %>%
  # Append sample metadata from file name
  mutate(
    # Extract temperature (number before c_)
    temperature = as.numeric(str_extract(file_name, "\\d+(?=c_)")),
    # Extract ce (number before ce)
    ce = as.numeric(str_extract(file_name, "\\d+(?=ce)")),
    # Create sample_name combining temperature and energy
    sample_name = paste0(temperature, "C_", ce, "eV"),
    # Convert to ordered factor
    sample_name = factor(
      sample_name,
      levels = paste0(
        rep(c(200, 285), each = 4), 
        "C_",
        rep(c(5, 23, 42, 60), times = 2), 
        "eV"
      ),
      ordered = TRUE
    )
  )
Found 8 mzML files in directory: ms_data/ 
Processing 8 mzML files...
Processing: 251103_rev4MRMs_200c_23ce.mzML 
Processing: 251103_rev4MRMs_200c_42ce.mzML 
Processing: 251103_rev4MRMs_200c_5ce.mzML 
Processing: 251103_rev4MRMs_200c_60ce.mzML 
Processing: 251103_rev4MRMs_285c_23ce.mzML 
Processing: 251103_rev4MRMs_285c_42ce.mzML 
Processing: 251103_rev4MRMs_285c_5ce.mzML 
Processing: 251103_rev4MRMs_285c_60ce.mzML 
Sample type classification:
- Samples: 8 
- Blanks: 0 
- Standards: 0 
Successfully annotated 14 unique compounds
Code
# 1. Summarize Data for Heatmaps (Chromatograms use raw sample_spectrums)
heatmap_data <- sample_spectrums %>%
  group_by(compound_name, transition, ce, temperature) %>%
  summarise(peak_max = log10(max(intensity, na.rm = TRUE)), .groups = "drop")

unique_compounds <- unique(heatmap_data$compound_name)

# 2. Begin Tabset Panel
cat("::: {.panel-tabset}\n\n")